﻿using System.Configuration;
using System.Data.Linq;
using SubsidiosBussinessLogic.Constants;
using SubsidiosBussinessLogic.DataAccess.Interfaces;
using SubsidiosBussinessLogic.Models;

namespace SubsidiosBussinessLogic.DataAccess.Context
{
    public class SubsidioDataContext : IDataContextFactory
    {

        /// <summary>
        /// IMP Data Context
        /// </summary>        
        private DataContext context;

        public DataContext Context
        {
            get { return context; }
        }

        public string ConnectionString { get; set; }


        #region .ctor
        public SubsidioDataContext()
        {
            ConnectionString = ConfigurationManager.ConnectionStrings[WebConstants.K_CONNECTIONSTRINGNAME].ToString();
            context = new SubsidioDatabaseDataContext(ConnectionString);
        }
    
        #endregion


        #region Miembros de IDataContextFactory

        public void SaveAll()
        {
            context.SubmitChanges();
        }

        #endregion
    }
}